﻿using _002_Service;
using IService;
using Microsoft.Extensions.DependencyInjection;
using System.Configuration;
using System.Data;
using System.Windows;

namespace _002_MVVM控制反转_IOC
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            ServiceProvider = ConfigService();
        }

        public static new App Current = (App)Application.Current;
        public IServiceProvider ServiceProvider { get; private set; } //专门提供IOC初始化和使用的对象

        private static IServiceProvider ConfigService()
        {
            var service = new ServiceCollection();

            //构建注入关系
            service.AddTransient<IStudentService, StudentService>();

            return service.BuildServiceProvider();
        }
    }

}
